package com.motherchild.user.service.impl;

import com.motherchild.user.dto.ShippingAddressDTO;
import com.motherchild.user.mapper.ShippingAddressMapper;
import com.motherchild.user.service.ShippingAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShippingAddressServiceImpl implements ShippingAddressService {

    @Autowired
    private ShippingAddressMapper shippingAddressMapper;

    @Override
    public List<ShippingAddressDTO> getAddressesByUserId(Long userId) {
        return shippingAddressMapper.selectAddressesByUserId(userId);
    }

    @Override
    public void addAddress(ShippingAddressDTO addressDTO) {
        shippingAddressMapper.insertAddress(addressDTO);
    }

    @Override
    public void updateAddress(ShippingAddressDTO addressDTO) {
        shippingAddressMapper.updateAddress(addressDTO);
    }

    @Override
    public void deleteAddress(Long id) {
        shippingAddressMapper.deleteAddress(id);
    }

    @Override
    public ShippingAddressDTO getAddressById(Long id) {
        return shippingAddressMapper.selectAddressById(id);
    }
}